﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebUI.BL.News;

namespace WebUI.AdminSite.News
{
    public partial class NewsMgmt : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            var repository = new NewsBL();
            var r = repository.GetNews().Select(x => new
                                                         {
                                                             Name=x.Title,
                                                             IdNews=x.NewsNo,
                                                             CreateDate=Convert.ToDateTime(x.CreatedDate.ToString()).ToShortDateString(),
                                                             StatusNews=x.Status,
                                                             IndexNews=x.IndexShow
                                                         });
            grdNews.DataSource = r.ToList();
            grdNews.DataBind();
        }
    }
}